<?php 
/**
* 接收catadd.php post过来的数据做处理
*
*/
define('ACC', true);
require('../include/init.php');
//用户检查
if (empty($_SESSION['username'])) {
	header("location:../index.php");
}

$cat = new CatModel();

$data = $cat->_fields($_POST);
//print_r($data);
$data = $cat->_autoFill($data);

$valids = $cat->_valiDat($data);
if (!$valids) {
	$info = implode($cat->getError());
	include(ROOT.'view/admin/info.html');
	exit;
}

$catname = $data['catname'];
if($cat->repeat($catname) !=0){
	$info = '栏目已存在';
	include(ROOT.'view/admin/info.html');
	exit;
}

//添加
if(!$cat->add($data)){
	$info = '添加失败';
	include(ROOT.'view/admin/info.html');
	exit;
}else {
	$info = '添加成功';
	include(ROOT.'view/admin/info.html');
}






?>